import {ref,onMounted,onUnmounted} from 'vue'
function useMouse(){
  const position = ref({x:0,y:0})
  const updateMouse = (e)=>{
    position.value.x = e.pageX
    position.value.y = e.pageY
  }
  onMounted(()=>{
    document.addEventListener("mousemove",updateMouse)
  })

  return position;

 
}

function useFollow(){
  const elem  = ref(null);

  const updateMouse = (e)=>{
    console.log(elem,"elem")
    elem.value.style.position = "absolute";
    elem.value.style.left = e.pageX + "px";
    elem.value.style.top = e.pageY + "px";
  }
  onMounted(()=>{
    document.addEventListener("mousemove",updateMouse)
  })
  onUnmounted(() => {
    document.removeEventListener("mousemove", updateMouse);s
  })
  return elem;
}
export {useMouse,useFollow};